package com.hy.hongying.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hy.hongying.bo.SelectVideoCommintBo;
import com.hy.hongying.bo.VideoCommintMyBo;
import com.hy.hongying.entity.VideoCommint;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface VideoCommitDao extends BaseMapper<VideoCommint> {
    /*
    查看自己的发布的视频
     */
    @Select("SELECT o.preurl url,c.ctime,c.id,c.info FROM t_vcommit c INNER JOIN t_video v " +
            "ON c.vid=v.id INNER JOIN t_oss o ON v.oid=o.id WHERE c.uid=${uid} and c.flag=1")
    List<VideoCommintMyBo> selectMyVideoCommint(@Param("uid") Integer uid);
    /*
    删除自己的评论
     */
    @Update("update t_vcommit set flag=2 where id=${id}")
    int delMyVideoCommint(@Param("id") Integer id);
    /*
    查看视频对应的评论以及评论的子品论数
     */
    @Select("SELECT id cid,info,uid FROM t_vcommit WHERE  vid=${vid}  AND repid=0")
    List<SelectVideoCommintBo> selectVideoCommintBo(@Param("vid")Integer vid);
    @Select("SELECT COUNT(1) FROM t_vcommit where repid=${cid} AND vid=0")
    int getVideoCommintBoNums(@Param("cid")Integer cid);
    /*
   查看视频对应的子评论以及评论的子子品论数
    */
    @Select("SELECT id cid,info,uid FROM t_vcommit WHERE  vid=0  AND repid=${cid}")
    List<SelectVideoCommintBo> selecCommintPreBo(@Param("cid")Integer cid);
    @Select("SELECT COUNT(1) FROM t_vcommit where repid=${cid} AND vid=0")
    int getCommintPreBoNums(@Param("cid")Integer cid);

}
